#pragma once
#include <iostream>
#include "Connection.hpp"
#include <memory>
#include <string>
#include "Socket.hpp"
#include"Common.hpp"
// 管理监听
const static int defaulted = -1;
class Listener : public Connection
{
public:
    Listener(int port = defaulted) : port(port),
                                     listen_socket(std::make_unique<SocketMoudle::TcpSocket>())
    {
        listen_socket->BuildListenSocket(port);
        SetNonBlock(listen_socket->GetSockFd());
        setEvents(EPOLLIN|EPOLLET);
    }
    ~Listener() {}
    void Recever() override
    {
        NetAddr client_addr;            
        while(true){
        int client_fd = listen_socket->Accept(&client_addr);
        }
    };
    void Sender() override {
        
    }
    void Excepter() override {}
    int getFd()override
    {
        return listen_socket->GetSockFd();
    }

private:
    int port;
    std::unique_ptr<SocketMoudle::Socket> listen_socket;
};